package cn.itsource.rpms.web.controller;

import cn.itsource.rpms.domain.Employee;
import cn.itsource.rpms.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@CrossOrigin
public class LoginController {

    @Autowired
    private IEmployeeService service;

    @RequestMapping(value="/login",method = RequestMethod.POST)
    @ResponseBody
    public Employee login(@RequestBody Employee employee){
        Employee one = service.queryOne(employee.getUsername());
        if(one==null){return null;}
        if(one.getPassword().equals(employee.getPassword())){
            return one;
        }
        return null;

    }
}
